package me.shep.wishlist.server;

import java.util.Properties;
import java.io.IOException;
import java.io.Reader;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class SqlMapManager {

	public static SqlMapClient getSqlMapClient(Properties authProps) {
		try {
			Reader reader = Resources.getResourceAsReader("me/shep/wishlist/server/SqlMapConfig.xml");
			SqlMapClient sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader, authProps);
			reader.close();
	        return sqlMapper;
		} catch (IOException e) {
			e.printStackTrace();
			throw new RuntimeException("MotoAds SqlMapManager: "+ e.getMessage(), e);
		}
	}
	
	public static SqlMapClient getSqlMapClient() {
		try {
			Reader reader = Resources.getResourceAsReader("me/shep/wishlist/server/SqlMapConfig_wcredent.xml");
			SqlMapClient sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
			reader.close();
	        return sqlMapper;
		} catch (IOException e) {
			e.printStackTrace();
			throw new RuntimeException("MotoAds SqlMapManager: "+ e.getMessage(), e);
		}
	}
}
